<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp"%>
<title>个人信息</title>
</head>
<body>
<%@ include file="/web/front/title/start.jsp"%>

<div class="grzxbj">
		<div class="selfinfo center">
		<div class="lfnav fl">
			<div class="ddzx">订单中心</div>
			<div class="subddzx">
				<ul>
					<li><a href="./order.jsp" >我的订单</a></li>
				</ul>
			</div>
			<div class="ddzx">个人中心</div>
			<div class="subddzx">
				<ul>
					<li><a href="./selfinfo.jsp">我的个人中心</a></li>
					<li><a href="./myaddress.jsp" style="color:#ff6700;font-weight:bold;">我的收货地址</a></li>
				</ul>
			</div>
		</div>
		<div class="rtcont fr" id="myaddress">
			
		</div>
		<div class="clear"></div>
		</div>
	</div>
<!-- self_info -->
		<%@ include file="/web/front/title/end.jsp"%>
	</body>
	
	<script type="text/javascript">
	init();
	function init(){	
		var userCode = '${user.code}';
			ajax({userCode:userCode},'/address/get.do','json',function(data){
				var html = '';
				if(data!="1"){
					html += "<div class='grzlbt ml40'>我的收货地址<a href='javascript:openupd(\""+ userCode +"\");' class='aaaa'>修改地址</a></div>";
					html += "<div class='subgrzl ml40'><span>收件人</span><span>" + data.name + "</span><span><a href=''>编辑</a></span></div>";
					html += "<div class='subgrzl ml40'><span>手机号</span><span id='tel'>" + data.tel + "</span><span><a href=''>编辑</a></span></div>"
					html += "<div class='subgrzl ml40'><span>收货地址</span><span id='tel'>" + data.addr1Name + "-" + data.addr2Name + "-" +data.addr3Name + "-" + data.addr4 + "</span><span><a href=''>编辑</a></span></div>"
					$("#myaddress").html(html);
				}else{
					html += "<div class='grzlbt ml40'>我的收货地址<a href='javascript:openadd(\""+ userCode +"\");' class='aaaa'>添加地址</a></div>";
					$("#myaddress").html(html);
					layer.msg("暂未填写收货地址，请及时填写",{
						time:1000
					})
				}
			})
	}
	
	function openadd(userCode){
		openLayer("/web/sys/address/add.jsp?userCode="+userCode,refresh);
	}
	
	function openupd(userCode){
		openLayer("/web/sys/address/updAddr.jsp?userCode="+userCode,refresh);
	}
		
	function refresh(){
		init();
	}
	</script>
	
	
</html>